//
//  WHVersionModel.m
//  WHPersonalData
//
//  Created by mac on 2018/5/29.
//  Copyright © 2018年 mac. All rights reserved.
//

#define archiverPaths  [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject] stringByAppendingPathComponent:@"versionModel.archiver"]


#import "WHVersionModel.h"
#import "NSObject+MJCoding.h"

@implementation WHVersionModel
//自定的模型的要实现
MJCodingImplementation

//保存
+ (BOOL)saveWHVersionModel:(WHVersionModel *)versionModel
{
    
    //DebugLog(@"保存成功");
    
    //DebugLog(@"archiverPath =%@",archiverPaths);
    
    return [NSKeyedArchiver archiveRootObject:versionModel toFile:archiverPaths];
    
}

//删除

+ (BOOL)deleteVersionModel{
    
    NSError *error;
    
    return [[NSFileManager defaultManager]removeItemAtPath:archiverPaths error:&error];
    
}

//取出
+ (instancetype)getVersionModel{
    
    if ([NSKeyedUnarchiver unarchiveObjectWithFile:archiverPaths]) {
        return [NSKeyedUnarchiver unarchiveObjectWithFile:archiverPaths];
    }else{
        
        WHVersionModel *versionModel = [[WHVersionModel alloc]init];
        return  versionModel;
    }

}



@end
